package com.lcz.mobilesafe.activity;

import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;

import com.lcz.mobilesafe.R;
import com.lcz.mobilesafe.widget.SettingItemView;

import butterknife.BindView;
import butterknife.ButterKnife;

/**设置中心
 * Created by hp on 2017/3/2.
 */
public class SettingActivity extends BaseActivity {
    @BindView(R.id.siv_update)
    SettingItemView sivUpdate;
    private SharedPreferences spf;//保存检查更新状态

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_setting);
        ButterKnife.bind(this);
        spf = getSharedPreferences("config", MODE_PRIVATE);
        boolean aotu_update = spf.getBoolean("aotu_update", true);
        if (aotu_update){
            sivUpdate.setChecked(true);
        }else{
            sivUpdate.setChecked(false);
        }

        sivUpdate.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (sivUpdate.isCheck()) {//勾选状态
                    spf.edit().putBoolean("aotu_update", false).commit();
                    sivUpdate.setChecked(false);
                } else {
                    spf.edit().putBoolean("aotu_update", true).commit();
                    sivUpdate.setChecked(true);
                }
            }
        });

    }

}
